import matplotlib.pyplot as plt
import numpy as np

def loadDataSet(fileName):
    dataMat = []
    fr = open(fileName)
    for line in fr.readlines():
        curLine = line.strip().split("\t")
        floatLine = list(map(float, curLine))
        dataMat.append(floatLine)
    return dataMat


def plotDataSet(fileName):
    dataMat = loadDataSet(fileName)
    n = len(dataMat)
    x = []; y = []
    for i in range(n):
        x.append(dataMat[i][0])
        y.append(dataMat[i][1])
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.scatter(x, y, s=20, c="red", alpha=0.5)
    plt.title("DataSet")
    plt.xlabel("X")
    plt.ylabel("Y")
    plt.show()


if __name__ == '__main__':
    fileName = "bikeSpeedVsIq_train.txt"
    plotDataSet(fileName)